{% load i18n misago_capture %}
<div class="card card-admin-info">
  <div class="card-body">
    <h4 class="card-title">
      {% trans "System checks" %}
    </h4>
  </div>
  <div id="admin-version-check" class="card-body border-top">
    <div class="media media-admin-check">
      <div class="media-check-icon">
        <div class="spinner-border" role="status">
          <span class="sr-only">Loading...</span>
        </div>
      </div>
      <div class="media-body">
        <h5>{% trans "Checking Misago version used by the site..." %}</h5>
        {% blocktrans trimmed %}
          Version check feature relies on the API operated by the Python Package Index (pypi.org) API to retrieve latest Misago release version.
        {% endblocktrans %}
      </div>
    </div>
  </div>
  {% if not checks.debug.is_ok %}
    <div class="card-body border-top">
      <div class="media media-admin-check">
        <div class="media-check-icon media-check-icon-danger">
          <span class="fas fa-times"></span>
        </div>
        <div class="media-body">
          <h5>{% trans "The site is running in DEBUG mode." %}</h5>
          {% blocktrans trimmed %}
            Error pages displayed in DEBUG mode will expose site configuration details like secrets and tokens to all visitors.
            This is MAJOR security risk.
          {% endblocktrans %}
        </div>
      </div>
    </div>
  {% endif %}
  {% if not checks.address.set_address %}
    <div class="card-body border-top">
      <div class="row">
        <div class="col">
          <div class="media media-admin-check">
            <div class="media-check-icon media-check-icon-danger">
              <span class="fas fa-times"></span>
            </div>
            <div class="media-body">
              <h5>{% trans "Forum address is not configured." %}</h5>
              {% trans "Links in e-mails sent by Misago will be broken." %}
            </div>
          </div>
        </div>
        <div class="col-auto">
          <a href="{% url 'misago:admin:settings:general:index' %}">
            <span class="fas fa-external-link-alt"></span>
          </a>
        </div>
      </div>
    </div>
  {% elif not checks.address.is_ok %}
    <div class="card-body border-top">
      <div class="row">
        <div class="col">
          <div class="media media-admin-check">
            <div class="media-check-icon media-check-icon-warning">
              <span class="fas fa-question"></span>
            </div>
            <div class="media-body">
              <h5>{% trans "Configured forum address appears to be incorrect." %}</h5>
              <div class="d-block">
                {% capture trimmed as set_address %}
                  <code>{{ checks.address.set_address }}</code>
                {% endcapture %}
                {% capture trimmed as correct_address %}
                  <code>{{ checks.address.correct_address }}</code>
                {% endcapture %}
                {% blocktrans trimmed with configured_address=set_address|safe correct_address=correct_address|safe %}
                  Your forum address is set to {{ configured_address }} while correct value appears to be {{ correct_address }}.
                {% endblocktrans %}
              </div>
              <div>
                {% trans "Links in e-mails sentby Misagoill be broken." %}
              </div>
            </div>
          </div>
        </div>
        <div class="col-auto">
          <a href="{% url 'misago:admin:settings:general:index' %}">
            <span class="fas fa-external-link-alt"></span>
          </a>
        </div>
      </div>
    </div>
  {% endif %}
  {% if not checks.https.is_ok %}
    <div class="card-body border-top">
      <div class="media media-admin-check">
        <div class="media-check-icon media-check-icon-warning">
          <span class="fas fa-question"></span>
        </div>
        <div class="media-body">
          <h5>{% trans "The site is not running over HTTPS." %}</h5>
          {% blocktrans trimmed %}
            Browsers may warn users visiting the site about it being insecure. Search engines will lower its position in search results.
          {% endblocktrans %}
        </div>
      </div>
    </div>
  {% endif %}
  {% if not checks.cache.is_ok %}
    <div class="card-body border-top">
      <div class="media media-admin-check">
        <div class="media-check-icon media-check-icon-danger">
          <span class="fas fa-times"></span>
        </div>
        <div class="media-body">
          <h5>{% trans "Cache is disabled." %}</h5>
          {% blocktrans trimmed %}
            This will cause degraded performance and increased CPU usage by the site, possibly leading to increased hosting costs.
          {% endblocktrans %}
        </div>
      </div>
    </div>
  {% endif %}
  {% if not checks.data_downloads.is_ok %}
    <div class="card-body border-top">
      <div class="media media-admin-check">
        <div class="media-check-icon media-check-icon-danger">
          <span class="fas fa-times"></span>
        </div>
        <div class="media-body">
          <h5>
            {% blocktrans trimmed count downloads=checks.data_downloads.count %}
              There is {{ downloads }} unprocessed data download request.
            {% plural %}
              There are {{ downloads }} unprocessed data download requests.
            {% endblocktrans %}
          </h5>
          {% blocktrans trimmed %}
            Cron task that should process user data download requests is not running.
          {% endblocktrans %}
        </div>
      </div>
    </div>
  {% endif %}
  {% if not checks.inactive_users.is_ok %}
    <div class="card-body border-top">
      <div class="row">
        <div class="col">
          <div class="media media-admin-check">
            <div class="media-check-icon media-check-icon-warning">
              <span class="fas fa-question"></span>
            </div>
            <div class="media-body">
              <h5>
                {% blocktrans trimmed count users=checks.inactive_users.count %}
                  There is {{ users }} inactive user accounts.
                {% plural %}
                  There are {{ users }} inactive users accounts.
                {% endblocktrans %}
              </h5>
              {% blocktrans trimmed %}
                The site may be targeted by bots, is not sending activation e-mails, or is not configured to delete inactive user accounts.
              {% endblocktrans %}
            </div>
          </div>
        </div>
        <div class="col-auto">
          <a href="{% url 'misago:admin:users:index' %}?is_inactive=1">
            <span class="fas fa-external-link-alt"></span>
          </a>
        </div>
      </div>
    </div>
  {% endif %}
</div>